package com.cloudree.gllib.surface;

import android.content.Context;
import android.view.MotionEvent;

import com.cloudree.gllib.render.IBORender;

/**
 * Created by Administrator on 2017/8/22.
 */
public class IBOSurface extends BaseGLSurface {
    private float sx;
    private float sy;
    private float cx;
    private float cy;
    private IBORender mRender;
    private float density;

    public IBOSurface(Context context) {
        super(context);
        mRender = new IBORender();
        setRenderer(mRender);
        density = getResources().getDisplayMetrics().density;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        float dx;
        float dy;
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                sx = event.getX();
                sy = event.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                dx = event.getX() - sx;
                dy = event.getY() - sy;
                mRender.mDeltaY = dy / density;
                mRender.mDeltaX = dx / density;
                break;
        }

        return true;
    }
}
